<?php
/**
 * Created by PhpStorm.
 * User: dai
 * Date: 2017/12/14
 * Time: 12:14
 */

namespace App\Http\Util;


use Carbon\Carbon;

class Common
{
    public static function upload($file)
    {
        $now = Carbon::now();
        $year = $now->year;
        $month = $now->month;

        $ext = $file->getClientOriginalExtension();     // 扩展名

        $filename = $now->format('YmdHis'). '-' . str_random('4') . '.' . $ext;
        $bool = $file->storeAs($year . '/' . $month, $filename, 'public_uploads');

        return '/uploads/'.$bool;
    }
}